From d28edc50476a66c1f3d4674adf2c4b440b3bf195 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 12 Feb 2026 18:02:02 -0800 Subject: [PATCH] [PATCH] QFileSystemEngine: handle copy_file_range() returning ENOSYS error This shouldn't have happened, because minimum-linux_p.h would have declared our need for a Linux kernel 4.5 or higher. I think the issue is not the kernel, but a container wrapping the Qt application and filtering system calls for security. If this container hasn't been updated to know about the system call, it may cause an ENOSYS error. Because we now handle the condition, this commit removes the 4.5 minimum Linux version requirement from minimum-linux_p.h. [ChangeLog][QtCore][QFile] Added a workaround to a compatibility issue of the copy() implementation in some containerized Linux environments, which could cause the file copy to fail with a "Function not implemented" error. This is believed to be a bug in the container runtime, not Qt, in that the container wrongly filtered the copy_file_range(2) system call that the Linux kernel supports. Fixes: QTBUG-144142 Change-Id: Iedbf805486ad79e7127dfffd22043889359563fd Reviewed-by: Ivan Solovev Reviewed-by: Ahmad Samir (cherry picked from commit b1b45ca4441db9e880e3a7fc7f4e8aa3af870eb6) Reviewed-by: Qt Cherry-pick Bot (cherry picked from commit 7b8591ac572079e59f856fb0ac7f4e3312f6dd43) Gbp-Pq: Name upstream_QFileSystemEngine-handle-copy_file_range-returning-E.patch --- src/corelib/global/minimum-linux_p.h | 5 ----- src/corelib/io/qfilesystemengine_unix.cpp | 1 + 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/corelib/global/minimum-linux_p.h b/src/corelib/global/minimum-linux_p.h index 86226326f..b2c74c5c3 100644 --- a/src/corelib/global/minimum-linux_p.h +++ b/src/corelib/global/minimum-linux_p.h @@ -41,7 +41,6 @@ QT_BEGIN_NAMESPACE * - accept4 2.6.28 * - renameat2 3.16 QT_CONFIG(renameat2) * - getrandom 3.17 QT_CONFIG(getentropy) - * - copy_file_range 4.5 QT_CONFIG(copy_file_range) * - statx 4.11 STATX_BASIC_STATS */ @@ -51,10 +50,6 @@ QT_BEGIN_NAMESPACE # define QT_ELF_NOTE_OS_MAJOR 4 # define QT_ELF_NOTE_OS_MINOR 11 # define QT_ELF_NOTE_OS_PATCH 0 -#elif QT_CONFIG(copy_file_range) -# define QT_ELF_NOTE_OS_MAJOR 4 -# define QT_ELF_NOTE_OS_MINOR 5 -# define QT_ELF_NOTE_OS_PATCH 0 #elif QT_CONFIG(getentropy) # define QT_ELF_NOTE_OS_MAJOR 3 # define QT_ELF_NOTE_OS_MINOR 17 diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 94349295d..5c2de01c5 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -1204,6 +1204,7 @@ auto QFileSystemEngine::cloneFile(int srcfd, int dstfd, const QFileSystemMetaDat switch (errno) { case EINVAL: // observed with some obscure filesystem combinations case EXDEV: // Linux can't do xdev file copies (FreeBSD can) + case ENOSYS: // caused by some containers wrongly filtering the system call break; default: -- 2.30.2